#ifndef TARGET_TRACKER_H
#define TARGET_TRACKER_H

#include <opencv2/opencv.hpp>
#include <vector>
#include "armor.h"

struct TrackedTarget {
    Armor armor;
    int lost_count;
    int tracked_count;
    std::vector<cv::Point2f> trajectory;
    cv::KalmanFilter kf;
};

class TargetTracker {
public:
    TargetTracker();
    void update(const std::vector<Armor>& detected_armors);
    Armor selectTarget();
    cv::Point2f predictHitPoint(const Armor& target, double bullet_speed);
    void drawPrediction(cv::Mat& frame, const cv::Point2f& predict_point);
    
private:
    std::vector<TrackedTarget> targets_;
    int max_lost_count_;
    double bullet_speed_;
    
    void initKalmanFilter(cv::KalmanFilter& kf);
    cv::Point2f applyKalmanFilter(cv::KalmanFilter& kf, const cv::Point2f& measurement);
};

#endif